<template>
  <el-dialog
      :title="title"
      append-to-body
      @close="dialogClose"
      :visible.sync="visible"
      v-bind.sync="$attrs"
      :width="width">
    <v2-form
        ref="form"
        :form-data="formData"
        :hide-button="true"
        :inline="inline"
        :label-position="pos"
        @submit="onSubmitV2"
        :fields="fields">
    </v2-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="dialogClose" :size="size">取 消</el-button>
      <el-button type="primary" @click="onSubmit" :size="size" >确 定</el-button>
  </span>
  </el-dialog>
</template>

<script>
import http from '@/network/http'
import util from "utils/util";
import qs from "qs" ;
import ApiResponse from "utils/ApiResponse";
import commons from "utils/commons";
export default {
  name: "dialogForm",
  props:{
    title: '' ,
    size: {
      type: String ,
      default: 'small'
    },
    inline: false ,
    value: false ,
    width: {
      type: String ,
      default: '480px'
    },
    btnText: {
      type: String ,
      default: '保存'
    },
    pos: {
      type: String ,
      default: 'right'
    } ,
    fields:{
      type: Array ,
      default(){
        return []
      }
    },
    formData:{
      type: Object ,
      default(){
        return {}
      }
    }
  },
  created(){
  },
  mounted() {

  },
  data(){
    return {

    }
  },
  methods:{


    dialogClose(){
      this.$emit("input",false);
    },
    onSubmit(){
      this.$refs.form.submit()
    },
    onSubmitV2(){
      this.$emit("submit",this.formData)
      this.dialogClose()
    },
    emptyValue(){

    }
  },
  computed:{
    visible:{
      get(){
        return this.value ;
      },
      set(val){
        this.$emit("input",val)
      }
    },
  },
  watch:{
  }
}
</script>

<style scoped>
  .is-hidden{display: none}
</style>
